#!/usr/bin/perl

my $bulksms_config_file = '/etc/sms.cfg';

use Net::SMS::2Way;

my $sms = Net::SMS::2Way->new({config => $bulksms_config_file}) || die "FATAL: Could not create Net::SMS::2Way object!\n";

my @inbox = $sms->get_inbox( "0" );

my ($status_code, $status_desc, $info) = split( /\|/, shift(@inbox) );

die "FATAL: Status code = $status_code, desc = $status_desc\n" if $status_code > 0;

print "Msg ID\t\tDate & Time\t\tSender\t\tMessage\n";
print "----------------------------------------------------------------\n";

my $message_count = 0;

foreach my $line (@inbox)
{
	my ($msg_id, $sender, $message, $recv_time, $msisdn, $ref_batch_id) = split /\|/, $line;

	print "$msg_id\t$recv_time\t$sender\t$message\n";
	$message_count++;
}

print "----------------------------------------------------------------\n";
print "Message Count: $message_count\n";
